<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css">
    <link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id='link'>
</head>

<body style="overflow:hidden; padding:10px;">
    <form>
        <table class="formtable" style="width:580px;" id="app">

            <tbody>

                <tr>
                    <td class="tlabel">班级编号</td>
                    <td>
                        <input type="text" class="forminput inputstyle1" id="classnum" value="{$info.classnum}">
                    </td>
                </tr>

                <tr>
                    <td class="tlabel">班级名称</td>
                    <td>
                        <input type="text" class="forminput inputstyle1" id="classname" value="{$info.classname}">
                    </td>
                </tr>
                <tr>
                    <td class="tlabel">班主任</td>
                    <td>
                        <select type="text" id="teacherid"  class="select"  v-model="checked">
                            <option value="">
                                请选择
                               </option>
                               <option v-for="item in list" :value='item.id'>
                                {{item.teachername}}
                               </option>
                           </select>
                    </td>
                </tr>

              





            </tbody>

        </table>

        <div class="formbtn">
            <input type="button" value="保存" class="btnsave">
            <input type="button" value="取消" class="btncancel">
        </div>
        <input type="hidden" id="id" value="{$info.id}" />
    </form>


</body>
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/vue2.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script>
   
    var menu = new Vue({
        el: '#app',
        data: {
            checked: "{$info.teacherid}",
            list: []
        },
        methods: {
            getdata: function () {
                var _self = this;//保存this的指向

                $.get('/Index/Teacher/GetTeacherList', function (data) {
                    _self.list = data;
                });
            }

        },
        created: function () {  //初始化事件里边去调用查询方法
            this.getdata();
        }
    });

    $(function () {
        $(".btnsave").click(function () {
            var id = $("#id").val();
            var classnum = $("#classnum").val();
            var classname = $("#classname").val();
            var teacherid = $("#teacherid").val();
          
            if(classnum==""){
				layer.msg("请输入班级编号");
				return;
			}else if(classname==""){
				layer.msg("请输入班级名称");
				return;
			}


            $.post("/Index/Myclass/Add", { "id": id, "classnum": classnum, "classname": classname,"teacherid":teacherid }, function (data) {
                if (data.status == 200) {
                    var index = parent.layer.getFrameIndex(window.name);
                    window.parent.iframe.contentWindow.location.reload(true);
                    console.log(window.parent.iframe);
                    parent.layer.close(index);
                } else {
                    layer.msg(data.message);
                }
            });
        });
        $(".btncancel").click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
    });


</script>

</html>